import request from '@/utils/request'


// 查询列表
export function listField(query) {
  return request({
    url: '/form/config/field/list',
    method: 'get',
    params: query
  })
}

// 查询详细
export function getField(id) {
  return request({
    url: '/form/config/field/' + id,
    method: 'get'
  })
}

// 新增
export function addField(data) {
  return request({
    url: '/form/config/field',
    method: 'post',
    data: data
  })
}

// 修改
export function updateField(data) {
  return request({
    url: '/form/config/field',
    method: 'put',
    data: data
  })
}

// 删除
export function delField(id) {
  return request({
    url: '/form/config/field/' + id,
    method: 'delete'
  })
}

// 验证代码是否重复
export function basicCodeValid(basicCode, id, parentId) {
  let url = '/form/config/field/basicCodeValid?basicCode=' + basicCode + '&id=' +id;
  if (parentId != null && parentId != undefined) {
    url += '&parentId=' + parentId;
  }
  return request({
    url: url,
    method: 'get'
  })
}

// 新增页获取编码、序号
export function getCodeSortNum() {
  return request({
    url: '/form/config/field/getCodeSortNum',
    method: 'get'
  })
}

// 查询引用属性列表
export function listRefField(query) {
  return request({
    url: '/form/config/field/reflist',
    method: 'get',
    params: query
  })
}

// 查询引用属性列表(选择引用属性时)
export function listSelectRefField(query) {
  return request({
    url: '/form/config/field/selectReflist',
    method: 'get',
    params: query
  })
}

// 新增引用属性
export function addRefField(data) {
  return request({
    url: '/form/config/field/addRef',
    method: 'post',
    data: data
  })
}

// 新增引用属性
export function addRefFieldForFilters(data) {
  return request({
    url: '/form/config/field/addRefForFilters',
    method: 'post',
    data: data
  })
}

// 删除引用属性
export function delRefField(data) {
  return request({
    url: '/form/config/field/delRef',
    method: 'post',
    data: data
  })
}

// 保存布局
export function addLayout(data) {
  return request({
    url: '/form/config/field/saveLayout',
    method: 'post',
    data: data
  })
}

// 查询现有布局
export function layoutList(query) {
  return request({
    url: '/form/config/field/layoutList',
    method: 'get',
    params: query
  })
}

// 查询模板引用属性(表单显示设计器用)
export function listElement(query) {
  return request({
    url: '/form/config/field/emlist',
    method: 'get',
    params: query
  })
}

// 复制模板
export function copyTemplate(data) {
  return request({
    url: '/form/config/field/copyTemplate',
    method: 'post',
    data: data
  })
}

export function getDictList(id){
  return request({
    url: '/form/config/field/getDictList/' + id,
    method: 'get'
  })
}



